package com.snackshop.controller;

import com.snackshop.pojo.vo.R;
import com.snackshop.pojo.vo.ResponseState;
import lombok.extern.java.Log;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@Log
public class TestController {
    @GetMapping("/test")
    // @PreAuthorize("hasAuthority('sys:user:test')")
    public R test(String name){
        String name1 = SecurityContextHolder.getContext().getAuthentication().getName();
        log.info(name1);
        Map<String,String> map = Map.of("name",name);
        return R.RESULT(ResponseState.SUCCESS,map);
    }
}
